home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP13.ZIP / PATRON / TENANT.H < prev   
C/C++ Source or Header  |  1993-07-19  |  7KB  |  225 lines

  1. /*
  2.  * TENANT.H
  3.  * Modifications for Chapter 13
  4.  *
  5.  * Definitions and function prototypes for the CTenant class
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _TENANT_H_
  18. #define _TENANT_H_
  19.  
  20.  
  21. class __far CImpIOleClientSite : public IOleClientSite
  22.     {
  23.     protected:
  24.         ULONG               m_cRef;      //Interface reference count.
  25.         class CTenant FAR * m_pTen;      //Back pointer to the object.
  26.         LPUNKNOWN           m_punkOuter; //Controlling unknown for delegation.
  27.  
  28.     public:
  29.         CImpIOleClientSite(class CTenant FAR *, LPUNKNOWN);
  30.         ~CImpIOleClientSite(void);
  31.  
  32.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  33.         STDMETHODIMP_(ULONG) AddRef(void);
  34.         STDMETHODIMP_(ULONG) Release(void);
  35.  
  36.         STDMETHODIMP SaveObject(void);
  37.         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER FAR *);
  38.         STDMETHODIMP GetContainer(LPOLECONTAINER FAR *);
  39.         STDMETHODIMP ShowObject(void);
  40.         STDMETHODIMP OnShowWindow(BOOL);
  41.         STDMETHODIMP RequestNewObjectLayout(void);
  42.     };
  43.  
  44. typedef CImpIOleClientSite FAR * LPIMPIOLECLIENTSITE;
  45.  
  46.  
  47.  
  48. class __far CImpIAdviseSink : public IAdviseSink
  49.     {
  50.     protected:
  51.         ULONG               m_cRef;      //Interface reference count.
  52.         class CTenant FAR * m_pTen;      //Back pointer to the object.
  53.         LPUNKNOWN           m_punkOuter; //Controlling unknown for delegation.
  54.  
  55.     public:
  56.         CImpIAdviseSink(class CTenant FAR *, LPUNKNOWN);
  57.         ~CImpIAdviseSink(void);
  58.  
  59.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  60.         STDMETHODIMP_(ULONG) AddRef(void);
  61.         STDMETHODIMP_(ULONG) Release(void);
  62.  
  63.         STDMETHODIMP_(void)  OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  64.         STDMETHODIMP_(void)  OnViewChange(DWORD, LONG);
  65.         STDMETHODIMP_(void)  OnRename(LPMONIKER);
  66.         STDMETHODIMP_(void)  OnSave(void);
  67.         STDMETHODIMP_(void)  OnClose(void);
  68.     };
  69.  
  70.  
  71. typedef CImpIAdviseSink FAR * LPIMPIADVISESINK;
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. /*
  79.  * Tenant class describing an individual piece of data in a page.
  80.  * It knows where it sits, what object is inside of it, and what
  81.  * its idenitifer is such that it can find it's storage within a page.
  82.  */
  83.  
  84. //Patron Objects clipboard format
  85. typedef struct tagPATRONOBJECT
  86.     {
  87.     POINTL      ptl;        //Location of object
  88.     POINTL      ptlPick;    //Pick point from drag-drop operation.
  89.     SIZEL       szl;        //Extents of object (absolute)
  90.     FORMATETC   fe;         //Actual object format.
  91.     } PATRONOBJECT, FAR * LPPATRONOBJECT;
  92.  
  93.  
  94.  
  95. //Values for hit-testing, drawing, and resize-tracking tenants
  96. #define CXYHANDLE       5
  97.  
  98. //Tenant types (not persistent, but determined at load time)
  99. typedef enum
  100.     {
  101.     TENANTTYPE_NULL=0,
  102.     TENANTTYPE_STATIC,
  103.     TENANTTYPE_EMBEDDEDOBJECT,
  104.     TENANTTYPE_EMBEDDEDFILE,
  105.     TENANTTYPE_EMBEDDEDOBJECTFROMDATA,
  106.     TENANTTYPE_LINKEDOBJECT,
  107.     TENANTTYPE_LINKEDFILE,
  108.     TENANTTYPE_LINKEDOBJECTFROMDATA
  109.     } TENANTTYPE, FAR * LPTENANTTYPE;
  110.  
  111.  
  112. //State flags
  113. #define TENANTSTATE_DEFAULT      0x00000000
  114. #define TENANTSTATE_SELECTED     0x00000001
  115. #define TENANTSTATE_OPEN         0x00000002
  116. #define TENANTSTATE_SHOWTYPE     0x00000004
  117.  
  118.  
  119. class __far CTenant : public IUnknown
  120.     {
  121.     friend CImpIOleClientSite;
  122.     friend CImpIAdviseSink;
  123.  
  124.     private:
  125.         HWND            m_hWnd;             //Pages window, same as CPages.
  126.         DWORD           m_dwID;             //Persistent DWORD identifier
  127.         DWORD           m_cOpens;           //Count calls to FOpen.
  128.  
  129.         BOOL            m_fInitialized;     //Something here?
  130.         LPUNKNOWN       m_pObj;             //The object that lives here.
  131.         LPSTORAGE       m_pIStorage;        //Sub-storage for this tenant
  132.  
  133.         FORMATETC       m_fe;               //As used to create the object.
  134.         DWORD           m_dwState;          //State flags
  135.         RECTL           m_rcl;              //Space of this object.
  136.  
  137.         class CPages FAR *m_pPG;            //Pages window
  138.  
  139.         TENANTTYPE      m_tType;            //Type identifier
  140.         ULONG           m_cRef;             //We're an object now!
  141.         LPOLEOBJECT     m_pIOleObject;      //IOleObject on m_pObj
  142.         LPVIEWOBJECT    m_pIViewObject;     //IViewObject on m_pObj
  143.  
  144.         LPOLECLIENTSITE m_pIOleClientSite;  //Our interfaces
  145.         LPADVISESINK    m_pIAdviseSink;
  146.  
  147.         //CHAPTER13MOD
  148.         LPMONIKER       m_pmk;              //Relative moniker.
  149.         LPMONIKER       m_pmkFile;          //Container document moniker.
  150.         //End CHAPTER13MOD
  151.  
  152.     /*
  153.      * This flag is used exculsively by the implementation of
  154.      * IOleUILinkContainer on the page we're in for the Links Dialog.
  155.      * Since we never use it ourselves, public here is no big deal.
  156.      */
  157.     public:
  158.         BOOL            m_fLinkAvail;
  159.  
  160.  
  161.     protected:
  162.         BOOL    FObjectInitialize(LPUNKNOWN, LPFORMATETC, DWORD);
  163.         HRESULT CreateStatic(LPDATAOBJECT, LPFORMATETC, LPUNKNOWN FAR *);
  164.  
  165.     public:
  166.         CTenant(DWORD, HWND, CPages FAR *);
  167.         ~CTenant(void);
  168.  
  169.         //Gotta have an IUnknown for delegation.
  170.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  171.         STDMETHODIMP_(ULONG) AddRef(void);
  172.         STDMETHODIMP_(ULONG) Release(void);
  173.  
  174.         DWORD   GetID(void);
  175.         UINT    GetStorageName(LPSTR);
  176.         UINT    UCreate(TENANTTYPE, LPVOID, LPFORMATETC, LPPOINTL
  177.                     , LPSIZEL, LPSTORAGE, LPPATRONOBJECT, DWORD);
  178.         BOOL    FLoad(LPSTORAGE, LPFORMATETC, LPRECTL);
  179.         BOOL    FOpen(LPSTORAGE);
  180.         void    Close(BOOL);
  181.         BOOL    Update(void);
  182.         void    Destroy(LPSTORAGE);
  183.  
  184.         void    Select(BOOL);
  185.         void    ShowAsOpen(BOOL);
  186.         void    ShowYourself(void);
  187.         void    AddVerbMenu(HMENU, UINT);
  188.         void    CopyEmbeddedObject(LPDATAOBJECT, LPFORMATETC, LPPOINTL);
  189.  
  190.         //CHAPTER13MOD
  191.         void    CopyLinkedObject(LPDATAOBJECT, LPFORMATETC, LPPOINTL);
  192.         void    NotifyOfRename(LPSTR, LPMONIKER, LPMONIKER);
  193.         void    StorageGet(LPSTORAGE FAR *);
  194.         //End CHAPTER13MOD
  195.  
  196.         void    ShowObjectType(BOOL);
  197.         BOOL    Activate(DWORD);
  198.         void    Draw(HDC, DVTARGETDEVICE FAR *, HDC, int, int, BOOL, BOOL);
  199.         void    Repaint(void);
  200.         void    Invalidate(void);
  201.  
  202.         TENANTTYPE  TypeGet(void);
  203.         BOOL        FIsSelected(void);
  204.         BOOL        FConvertToStatic(void);
  205.  
  206.         void    ObjectGet(LPUNKNOWN FAR *);
  207.         void    FormatEtcGet(LPFORMATETC, BOOL);
  208.         void    SizeGet(LPSIZEL, BOOL);
  209.         void    SizeSet(LPSIZEL, BOOL);
  210.         void    RectGet(LPRECTL, BOOL);
  211.         void    RectSet(LPRECTL, BOOL);
  212.     };
  213.  
  214.  
  215. typedef CTenant FAR * LPTENANT;
  216.  
  217. //Return codes for UCreate
  218. #define UCREATE_FAILED              0
  219. #define UCREATE_GRAPHICONLY         1
  220. #define UCREATE_PLACEDOBJECT        2
  221.  
  222.  
  223.  
  224. #endif //_TENANT_H_
  225.